package org.desktop.intbox.business.categories.impl;

import org.desktop.intbox.business.categories.IFileCategoryEntity;
import org.desktop.intbox.business.categories.IFileType;

public class FileType extends FileCategoryEntity implements IFileType {

	public FileType() {
		super();
	}

	public FileType(final Integer color, final String name) {
		super(color, name);
	}

	public FileType(final Integer color) {
		super(color);
	}

	public FileType(final String name) {
		super(name);
	}

	@Override
	public void setName(final String name) {
		if(getName() != null) {
			throw new IllegalArgumentException("Should not change the name of a fle type");
		}
		super.setName(normalizeName(name).intern());
	}

	@Override
	public IFileCategoryEntity getEntryFor(final String extension, final double depthRatio) {
		return getEntryFor(extension);
	}
	
	@Override
	public IFileCategoryEntity getEntryFor(final String extension) {
		return extension != null && normalizeName(extension).equals(getName()) ? this : null;
	}
}
